import Taro, { Component } from '@tarojs/taro'
import { Image, View } from '@tarojs/components'
import './index.scss'
import classNames from 'classnames'
import { formatTime } from "@/utils/utils"
import { INTEGRAL_TYPE_NAME } from "@/config/types"
import gold from '@/market/assets/icon/gold.png'

interface IProps {
  list: any
  className: string
}

export default class RecordList extends Component<IProps, {}> {
  props: any

  static options = {
    addGlobalClass: true
  }

  render() {
    const { list=[], className } = this.props
    return (<View className={classNames('record-list', className)}>
      {list.map((i, k) => {
        return (<View key={k} className='record-item thin-border__b d-f a-i-c j-c-b'>
          <View className='record-left'>
            <View className='record-title'>{INTEGRAL_TYPE_NAME[i.type]}</View>
            <View className='record-time'>{formatTime(i.createdAt)}</View>
          </View>
          <View className='record-right d-f'>
            <View className={classNames('record-num bnn-number m-r-10', {
              ['record-plus']: i.score > 0,
              ['record-minus']: i.score < 0,
            })}>{i.score > 0 ? `+${i.score}` : `${i.score}`}</View>
            <Image src={gold} className='record-icon'/>
          </View>
        </View>)
      })}
    </View>)
  }
}
